﻿namespace Example
{
    using NodaTime;

    using Xunit;

    public sealed class NodaTimeDateTimeZoneFacts
    {
        [Fact]
        public void op_ForId_stringEuropeLondon()
        {
            var london = DateTimeZone.ForId("Europe/London");
            var offset = london.GetOffsetFromUtc(Instant.FromUtc(1942, 7, 1, 0, 0));

            Assert.Equal("+2", offset.ToString());
        }

        [Fact]
        public void op_ForId_stringEuropeParis()
        {
            var paris = DateTimeZone.ForId("Europe/Paris");
            var offset = paris.GetOffsetFromUtc(Instant.FromUtc(1900, 1, 1, 0, 0));

            Assert.Equal("+0:09:21", offset.ToString());
        }

        [Fact]
        public void op_GetZoneInterval_Instant()
        {
            var london = DateTimeZone.ForId("Europe/London");
            var interval = london.GetZoneInterval(Instant.FromUtc(2010, 6, 19, 0, 0));

            Assert.Equal("BST", interval.Name);
            Assert.Equal(Instant.FromUtc(2010, 3, 28, 1, 0), interval.Start);
            Assert.Equal(Instant.FromUtc(2010, 10, 31, 1, 0), interval.End);
            Assert.Equal(Offset.FromHours(1), interval.WallOffset);
            Assert.Equal(Offset.FromHours(1), interval.Savings);
        }
    }
}